//
//  CZStatus.swift
//  WeiBO28
//
//  Created by 飞奔的羊 on 16/5/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZStatus: NSObject {
	var created_at: String?
	var id: Int64 = 0
	var text: String?
	var source: String?
	var user: CZUser?
	//发布时间
	
	//转发数
	var reposts_count: Int = 0
	//评论数
	var comments_count: Int = 0
	//赞/数
	var attitudes_count: Int = 0
	//配图数据
	var pic_urls: [CZStatusPictureInfo]?
	var retweeted_status: CZStatus?
	
	 init(dic: [String: AnyObject]) {
	super.init()
		setValuesForKeysWithDictionary(dic)
	

	}
	
	override func setValue(value: AnyObject?, forKey key: String) {
		if key == "user" {
			
			guard let dic = value as? [String: AnyObject] else {
			return
			}
			user = CZUser(dic: dic)
		} else if key == "retweeted_status"{
		
			guard let dic = value as? [String: AnyObject] else {
			return
			}
			retweeted_status = CZStatus(dic: dic)
//			retweeted_status
		}  else if key == "pic_urls" {
			guard let dicArray = value as? [[String: AnyObject]] else
			{
			return
			}
			
			//创建一个空的数组
			var tempArray = [CZStatusPictureInfo]()
			//遍历字典数组
		 for dic in dicArray
			{
				let picInfo = CZStatusPictureInfo(dic: dic)
				 tempArray.append(picInfo)
			}
			
			pic_urls = tempArray
		} else {
			super.setValue(value, forKey: key)
		
		}
		
	}
	
	override func setValue(value: AnyObject?, forUndefinedKey key: String) {
		
	}
	
	
	
	
	
}
